package com.stlm2.core.exception;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
 * Author：fuchunyu
 * Date：2017/7/26
 * Description：接口异常处理类
 */

public class ExceptionHandler implements HandlerExceptionResolver {

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object object, Exception e) {

		//输出错误信息到控制台
		e.printStackTrace();

		//返回错误信息到error页面
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("info", "服务器异常:"+e.toString());

		return new ModelAndView("error", model);
	}

}
